<?php

function connectToDatabase() {
    require 'dbInfo.php';
    $db_server = mysql_connect($host, $username, $password);
    if (!$db_server
        )die("Cannot connect to the MySQL database!<br />Please
       contact your database administrator.");
    mysql_select_db($database) or die("Cannot select the database!<br />Please
       make sure it has been installed properly!");
    return $db_server;
}

/**
 * @desc Addes slashes to a string, and gets rid of HTML entities
 * @param string $str
 * @return string $str
 */
function sanitizeStr($str) {
    $str = strip_tags($str);
    $str = addslashes($str);
    return $str;
}

/**
 * @desc Removes slashes from a string
 * @param string $str
 * @return string $str
 */
function restoreStr($str) {
    $str = stripslashes($str);
    return $str;
}

/**
 * Hashes a given password
 * @param String Password to be hashed
 * @return String Returns the hashed password
 */
function encryptStr($str) {
    $str = crypt(md5($str), '$2a$13$6qpov45d80sd6f40DS465');
    $str = substr(strrchr($str, '.'), 1);
    return $str;
}

?>
